import { BelongsTo, Column, DataType, ForeignKey, HasMany, Model, Table } from 'sequelize-typescript'

@Table
export class Player extends Model<Player> {

  @Column(DataType.STRING)
  name: string

  @Column(DataType.INTEGER)
  num: number

  @ForeignKey(() => Team)
  @Column(DataType.INTEGER)
  teamId: number

  @BelongsTo(() => Team)
  team: Team
}

@Table
export class Team extends Model<Team> {

  @Column(DataType.STRING)
  name: string

  @HasMany(() => Player)
  players: Player[]
}